package com.travel.rabbit.controller.front;

import com.travel.rabbit.aop.LogAround;
import com.travel.rabbit.entity.Result;
import com.travel.rabbit.service.DistrictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 云澜
 * @date 2023/6/16 4:42 下午
 */
@Api(tags = "省市区地点")
@RestController
@RequestMapping("/district")
public class DistrictController {

    @Resource
    DistrictService districtService;

    @LogAround(keyName = "省市区地点[前台]",operationType = "根据父级ID获取子级")
    @ApiOperation(value = "根据父级ID获取子级",tags = {"省市区地点"})
    @GetMapping("/upid")
    public Result queryDistrictById(@RequestParam("upid")Integer upid){
        return Result.success(districtService.queryByPId(upid));
    }

    @LogAround(keyName = "省市区地点[前台]",operationType = "获取一级省份｜直辖市")
    @ApiOperation(value = "获取一级省份｜直辖市",tags = {"省市区地点"})
    @GetMapping("/firstDistrict")
    public Result firstDistrict(){
        return Result.success(districtService.firstDistrict());
    }

    @LogAround(keyName = "省市区地点[前台]",operationType = "缓存省市区")
    @ApiOperation(value = "缓存省市区",tags = {"省市区地点"})
    @GetMapping("/cache")
    public Result cacheDistrict(){
        districtService.cache();
        return Result.success();
    }
}